<template>
  <div
    class="block"
    :class="system.blockAnimation ? block.className : ''"
    :style="`background-image: url(${block.img});`"
  >
    <!-- <p>{{ block.name }}</p> -->
    <!-- <p>({{ x }}, {{ y }})</p> -->
  </div>
</template>

<script>
import {  getBlock } from "@/util/blNoise.js";
import { mapState } from "vuex";

export default {
  props: {
    x: {
      type: Number,
      required: true,
    },
    y: {
      type: Number,
      required: true,
    },
  },
  computed: {
    ...mapState("map", ["mapSeed", "mapSeedScale", "system"]),
    block() {
      return getBlock(this.x, this.y, this.mapSeed, this.mapSeedScale);
    },
  },
};
</script>

<style scoped>
.block {
  width: 50px;
  height: 50px;
  border: 1px solid rgb(0, 0, 0);
  box-sizing: border-box;
  font-size: 12px;

  background-repeat: no-repeat;
  background-size: cover;
}

.block.lava {
  animation: lava 5s infinite steps(16);
  background-size: 50px 800px;
}
@keyframes lava {
  0% {
    background-position: 0 0;
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.5);
  }
  100% {
    background-position: 0 -800px;
    filter: brightness(1);
  }
}

.block.water {
  animation: water 5s infinite steps(32);
  background-size: 50px 1600px;
}
@keyframes water {
  0% {
    background-position: 0 0;
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.5);
  }
  100% {
    background-position: 0 -1600px;
    filter: brightness(1);
  }
}
</style>